class Solution:
    def numWaterBottles(self, numBottles: int, numExchange: int) -> int:
        ans = numBottles
        # 剩余瓶数大于换瓶数，循环继续
        while numBottles >= numExchange:
            exchange = numBottles // numExchange # 可换数量
            ans += exchange
            remain = numBottles % numExchange # 剩余数量
            numBottles = exchange + remain # 更新
        
        return ans
#方法二数学
class Solution:
    def numWaterBottles(self, numBottles: int, numExchange: int) -> int:
        return numBottles + (numBottles - 1) // (numExchange - 1)
